package ch14;

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.layout.*;
import javafx.scene.*;
import javafx.scene.control.Button;
import javafx.geometry.*;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;

public class RotateTest extends Application {
    public static void main(String[] args) {
        launch(args);
    }

    public void start(Stage primaryStage) throws Exception {
        RotatePane pane = new RotatePane();
        Scene scene = new Scene(pane);
        primaryStage.setScene(scene);
        primaryStage.show();
    }
}

class RotatePane extends VBox {
    double a = 0;

    public RotatePane() {
        Rectangle rectangle = new Rectangle(60, 80);
        rectangle.setFill(Color.WHITE);
        rectangle.setStroke(Color.BLACK);
        setPadding(new Insets(20));
        setSpacing(20);
        Button button = new Button("xuanzhuan");
        button.setOnMousePressed(e -> {
            a += 15;
            rectangle.setRotate(a);
        });
        getChildren().addAll(rectangle, button);
    }
}